class Solution {
    public int findMin(int[] nums) {
        /**
         * 3,4,5,1,2,3
         * <=3
         *   0,0,1,1,1
         */
        int left = 0;
        int lastIdx = nums.length - 1;
        while (left <= lastIdx && nums[left] == nums[lastIdx]) {
            left++;
        }
        int lastVal = nums[lastIdx];
        int right = lastIdx;
        while (left < right) {
            int mid = (left + right) >> 1;
            if (nums[mid] <= lastVal) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return nums[right];
    }
}
